package com.kingbook.api.rest;

import com.kingbook.core.result.JSONResult;
import com.kingbook.services.ConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author Bucky
 * @Date 2019-11-05 22:56:45
 * @Version 1.0
 */
@Slf4j
@RestController
@RequestMapping("config")
public class ConfigRest {

    @Autowired
    ConfigService configService;

    /**
     * OSS秘钥配置数据
     */
    @GetMapping("oss")
    public JSONResult queryOssConfig() {
        JSONResult json = configService.queryOssConfig();
        log.info("---->{}", json.getData());
        return json;
    }

    @GetMapping("introUrls")
    public JSONResult getIntroUrls() {
        log.info("---->{}", "getIntroUrls");
        try {
            return configService.queryIntroUrls();
        } catch (Exception e) {
            log.error("---->获取引导页url失败.");
            return JSONResult.failed("获取引导页url失败");
        }
    }

}
